package com.sfzy.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sfzy.entity.CourseRating;
import com.sfzy.mapper.CourseRatingMapper;
import com.sfzy.service.CourseRatingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CourseRatingServiceImpl implements CourseRatingService {
    @Autowired
    private CourseRatingMapper courseRatingMapper;

    @Override
    public int addCourseRating(CourseRating courseRating) {
        return courseRatingMapper.addCourseRating(courseRating);
    }

    @Override
    public int deleteCourseRating(int id) {
        return courseRatingMapper.deleteCourseRating(id);
    }

    @Override
    public int updateCourseRating(CourseRating courseRating) {
        return courseRatingMapper.updateCourseRating(courseRating);
    }

    @Override
    public CourseRating getById3(int id) {
        return courseRatingMapper.getById3(id);
    }

    @Override
    public PageInfo<CourseRating> getByPage3(CourseRating courseRating, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<CourseRating> page = courseRatingMapper.getByPage3(courseRating);
        PageInfo<CourseRating> pageInfo = new PageInfo<>(page);
        return pageInfo;
    }
}
